#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string minWindow(string s, string t) {
        string ret;
        int hasht[58];
        for (char ch : t)
            hasht[ch - 'A']++;
        int hashs[58];
        int n = t.size();
        for (int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            if (++hashs[s[right] - 'A'] <= hasht[s[right] - 'A']) count++;
            if (count == n)
            {
                while (count == n)
                {
                    if (hashs[s[left] - 'A']-- <= hasht[s[left] - 'A']) count--;
                    left++;
                }
                string tem(s, left - 1, right - left + 2);
                if (ret.size() == 0 || ret.size() > tem.size()) ret = tem;
            }
        }
        return ret;
    }
};